﻿using MediatR;
using T_vehicle.API.Application.Command.ExpensesCommand;
using T_vehicle.Infrastructure.Interfacec;

namespace T_vehicle.API.Application.CommandHandlers.ExpensesCommandHandlers
{
    public class DelExpensesCommandHandlers : IRequestHandler<DelExpensesCommand, int>
    {
        private readonly IExpensesRepository expensesRepository;

        public DelExpensesCommandHandlers(IExpensesRepository expensesRepository)
        {
            this.expensesRepository = expensesRepository;
        }

        public async Task<int> Handle(DelExpensesCommand request, CancellationToken cancellationToken)
        {
            var list = await expensesRepository.GetModelAsync(request.ExpensesId);
            list.IsDel = true;
            var res = await expensesRepository.UpdateAsync(list);
            return res;
        }
    }
}
